package com.lxh.libmanager.services.impl;

import com.lxh.libmanager.dao.UserDao;
import com.lxh.libmanager.entity.User;
import com.lxh.libmanager.services.UserServices;
import com.lxh.libmanager.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserServicesImpl implements UserServices {
    
    @Autowired
    private UserDao userDao;
    
    @Override
    @Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
    public User doLogin(String name, String password) {
        System.out.println("按名字查询：");
        if(StringUtil.isNotEmpty(name,password)){
            User user = userDao.getUserByName(name);
            System.out.println(user);
            if(user!=null&&user.getPassword().equals(password)){
                return user;
            }
        }
        return null;
        
    }
}
